<template>
	<view class="add-bank-card">
		<NavBar title="新增银行卡" :isBack="true"></NavBar>
		<view class="content">
			<view class="card-info">
				<view class="row card-name">
					<view class="title">银行卡：</view>
					<input type="text" placeholder="银行卡名称" v-model="bankInfo.type">
				</view>
				<view class="row">
					<view class="title">卡&nbsp;&nbsp;&nbsp;号：</view>
					<input type="number" placeholder="银行卡号"  v-model="bankInfo.bank">
				</view>
			</view>
			<view class="hint">
				提醒：后续只能绑定该持卡人的银行卡
			</view>
			<view class="card-info">
				<view class="row card-name">
					<view class="title">持卡人：</view>
					<input type="text" placeholder="持卡人" v-model="bankInfo.name">
				</view>
				<view class="row card-name">
					<view class="title">身份证：</view>
					<input type="text" placeholder="身份证" v-model="bankInfo.card">
				</view>
				<view class="row">
					<view class="title">手机号：</view>
					<input type="number" placeholder="银行预留手机号" v-model="bankInfo.mobile">
					<image class="doubt" src="@/static/services/doubt.png"></image>
				</view>
			</view>
			<view class="verify-btn" @click="addServicesbank">
				验证信息
			</view>
		</view>

	</view>
</template>

<script setup>
	import {
		addbank
	} from '@/api/services.js'
	import {
		reactive,
		onMounted,
		toRefs
	} from 'vue'
	import {
		showToast
	} from '@/common/interactiveFeedback.js'
	const state = reactive({
		bankInfo: {
			mobile: "",
			card: "",
			bank: "",
			type: "",
			name: "",
		}
	})

	async function addServicesbank() {
		if (Object.values(state.bankInfo).includes("")) return showToast("银行卡信息不能为空")
		const res = await addbank(state.bankInfo)
		if (res.code) {
			showToast("添加成功")
			uni.navigateBack()
		}
		console.log(res, 'res');
	}
	onMounted(() => {

	})
	const {
		bankInfo
	} = toRefs(state)
</script>

<style lang="scss" scoped>
	.add-bank-card {
		.content {
			position: relative;
			z-index: 1;
			padding: 36rpx;

			.card-info {
				width: 678rpx;
				background: #FFFFFF;
				border-radius: 22rpx 22rpx 22rpx 22rpx;
				padding: 36rpx 27rpx;
				box-sizing: border-box;

				.card-name {
					border-bottom: 1rpx solid #F5F5F5;
					padding-bottom: 24rpx;
					margin-bottom: 38rpx;
				}

				.row {
					position: relative;
					display: flex;
					align-items: center;
					font-weight: bold;
					font-size: 26rpx;
					color: #333333;

					.title {
						font-weight: bold;
						font-size: 26rpx;
						color: #333333;
						margin-right: 32rpx;
					}

					input {
						font-weight: 500;
						font-size: 26rpx;
						color: #333333;
						width: 70%;
					}

					.doubt {
						width: 26rpx;
						height: 26rpx;
						position: absolute;
						right: 0rpx;
					}
				}
			}

			.hint {
				font-weight: bold;
				font-size: 18rpx;
				color: #999999;
				margin: 44rpx 0rpx 15rpx;
			}

			.verify-btn {
				text-align: center;
				width: 648rpx;
				height: 66rpx;
				line-height: 66rpx;
				background: #58DBCF;
				border-radius: 500rpx 500rpx 500rpx 500rpx;
				font-weight: 800;
				font-size: 30rpx;
				color: #FFFFFF;
				margin-top: 84rpx;
			}
		}

	}
</style>